﻿using System;
namespace Producers.Karis.Xtee.Riik.Ee.Producer.Karis {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="krUurijaJIsikud_paring", Namespace="http://producers.karis.xtee.riik.ee/producer/karis", Target=typeof(KrUurijaJIsikudParing))]
    public class KrUurijaJIsikudParingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IKrUurijaJIsikudParing clazz;
        
        public KrUurijaJIsikudParingSerializer(IKrUurijaJIsikudParing clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("j_registrikood");
            if (clazz.JRegistrikood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.JRegistrikood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : JRegistrikood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("j_nimetus");
            if (clazz.JNimetus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.JNimetus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : JNimetus");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "j_registrikood")) {
                goto j_registrikood;
            }
            else {
                if ((Reader.LocalName == "j_nimetus")) {
                    goto j_nimetus;
                }
                else {
                    return;
                }
            }
        j_registrikood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>krUurijaJIsikud_paring>j_registrikood");
            }
            clazz.JRegistrikood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("j_registrikood")).Value;
            goto START;
        j_nimetus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>krUurijaJIsikud_paring>j_nimetus");
            }
            clazz.JNimetus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("j_nimetus")).Value;
            goto START;
        }
    }
}
